<template name="slide">
  <music-list :title="title" :bg-image="bgImage" :songs="songs"></music-list>
</template>

<script type="text/ecmascript-6">
  import MusicList from "../music-list/music-list";
  import {mapGetters} from 'vuex'
  import {isValidMusic} from "../../common/js/song";
  import {createSong} from "../../common/js/song";

  let _this = null;

  export default {
    props: [],
    data(){
      return {
        songs:[]
      }
    },
    created(){
      this._getSongList()
    },
    mounted () {
      _this = this;
      _this.init();
    },
    methods: {
      init () {
      },
      _getSongList(){
        if(!this.disc.dissid){
          this.$router.push('/recommend')
        }
        const data = this.desc.cdlist[0].songlist
        this.songs = this._normalizeSongs(data)
      },
      _normalizeSongs(list){
        let ret = []
        list.forEach((musicData) => {
          if(isValidMusic(musicData)){
            ret.push(createSong(musicData))
          }
        })
        //============
        return ret
      }
    },
    watch: {},
    components: {MusicList},
    computed: {
      title(){
        return this.disc.dissname
      },
      bgImage(){
        return this.disc.imgurl
      },
      ...mapGetters([
        'disc',
        'desc',
      ])
    },

  }
</script>


<style lang="stylus" rel="stylesheet/stylus">
  @import '../../common/stylus/variable.styl';
.slide-enter-active,.slide-leave-active
  transition all 0.3s
.slide-enter,.slider-leave-to
  transform translate3d(100%,0,0)
</style>
